﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

/// <summary>
/// 战斗数据提示
/// </summary>
public class NumberTips : ShowHideBehaviour {

    private Text ShowDamageText;
    private float YieldSecond = 0.5f;

	// Use this for initialization
	void Start () {
        base.InitShowHide();
        this.ShowDamageText = GetComponent<Text>();
	}
	
	// Update is called once per frame
	void Update () {
        base.HandleToast(this.YieldSecond);
	}

    public void Show(int damage, string format, GameObject gameObject, float offset = 1f) {
        this.ShowDamageText.text = string.Format(format, damage);
        transform.position = Camera.main.WorldToScreenPoint(gameObject.transform.position + new Vector3(0, offset, 0));
        base.Show();
    }

    public void ShowHp(int num, GameObject gameObject, float offset = 1f) {
        this.Show(num, "<color=red>{0}</color>", gameObject, offset);
    }

    public void ShowMp(int num, GameObject gameObject, float offset = 1f) {
        this.Show(num, "<color=blue>{0}</color>", gameObject, offset);
    }

    public void ShowVit(int num, GameObject gameObject, float offset = 1f) {
        this.Show(num, "<color=white>{0}</color>", gameObject, offset);
    }

    public void ShowHpMpVit(int hp, int mp, int vit, GameObject gameObject, float offset = 1) {
        this.ShowDamageText.text = string.Format("<color=red>{0}</color>\n<color=blue>{1}</color>\n<color=white>{2}</color>", hp, mp, vit);
        transform.position = Camera.main.WorldToScreenPoint(gameObject.transform.position + new Vector3(0, offset, 0));
        base.Show();
    }
}
